package org.xinhe.example.quartz.management.common;

/**
 * <p>Title: ApiResponse</p>
 * <p>Date: 17/1/2 </p>
 * <p>Description: </p>
 *
 * @author xinhe.sun
 */
public class ApiResponse<T> {
    private static final String CODE_SUCCESS = "1";
    private static final String CODE_FAIL = "0";

    private String status;

    private String errCode;

    private String msg;

    private T data;

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getErrCode() {
        return errCode;
    }

    public void setErrCode(String errCode) {
        this.errCode = errCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static ApiResponse succesResponse() {
        ApiResponse apiResponse = new ApiResponse();
        apiResponse.setStatus(CODE_SUCCESS);
        return apiResponse;
    }

    public static ApiResponse failedResponse() {
        ApiResponse apiResponse = new ApiResponse();
        apiResponse.setStatus(CODE_FAIL);
        return apiResponse;
    }

    public static ApiResponse failedWithMsg(String msg){
        ApiResponse apiResponse = new ApiResponse();
        apiResponse.setStatus(CODE_FAIL);
        apiResponse.setMsg(msg);
        return apiResponse;
    }
}
